#include <iostream>
#include <list>
using namespace std;
list<int> split_num(int & num)
{
    list<int> l;
    while(num%10 != 0)
    {
        l.push_back(num%10);
        l.reverse();
        num /=10;
    }
    return l;
}
int main() {

    int num = 12345;
    list<int> a;
    list<int>::iterator iter;
    a = split_num(num);
    for(iter=a.begin();iter!=a.end();iter++)
    {
        cout<<*iter<<" ";
    }
    return 0;
}